<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>

    <!--MyHeader-->
    <div th:include="common::MyHeader"></div>
    <!-- End of MyHeader -->

</head>

<body id="page-top">

<!-- Page Wrapper -->
<div id="wrapper">

    <!-- Sidebar -->
    <ul th:replace="common::Sidebar(${session.user.userName})"></ul>
    <!-- End of Sidebar -->

    <!-- Content Wrapper -->
    <div id="content-wrapper" class="d-flex flex-column">

        <!-- Main Content -->
        <div id="content">

            <!-- Topbar -->
            <div th:include="common::Topbar(${session.user.userName})"></div>
            <!-- End of Topbar -->

            <!-- Begin Page Content -->
            <div class="container-fluid">

                <!-- Page Heading -->
                <div class="d-sm-flex align-items-center justify-content-between mb-4">
                    <h1 class="h3 mb-0 text-gray-800">查看书架详情</h1>
                </div>


                <!-- Content Column -->
                <div>
                    <table id="mytab" class="table table-hover"></table>
                </div>


            </div>

        </div>
        <!-- /.container-fluid -->

    </div>
    <!-- End of Content Wrapper -->

</div>
<!-- End of Page Wrapper -->

<!-- Scroll to Top Button-->
<a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
</a>
<script th:src="@{/webjars/popper.js/1.11.1/dist/umd/popper.min.js}"></script>
<script th:src="@{/bootstraptable/bootstrap-table.min.js}"></script>
<script th:src="@{/bootstraptable/bootstrap-table-zh-CN.min.js}"></script>
<!-- Logout Modal-->
<div th:include="common::LogoutModal"></div>


</body>

</html>

<script>
    $('#mytab').bootstrapTable({
            url: "/data1.json",
        queryParams: "queryParams",
        toolbar: "#toolbar",
        sidePagination: "true",
        striped: true, // 是否显示行间隔色
        //search : "true",
        uniqueId: "ID",
        pageSize: "5",
        pagination: true, // 是否分页
        sortable: true, // 是否启用排序
            queryParams: function (params) {   //设置查询参数
                var param = {
                    pageNumber: params.pageNumber,
                    pageSize: params.pageSize,
                    courseName: $('#courseMainName').val(),
                    startDate: $('#startDate').val(),　　//获取开始时间戳
                    endDate: $('#endDate').val(),　　　 //获取结束时间戳
                    deptId: $('#forDeptId option:selected').val(),//部门
                    status: $('#statusId option:selected').val(),//状态
                };
                return param;
            },
            columns: [
                {
                    title: '创建日期',
                    field: 'gmtCreate',
                    formatter: function (value) {
                        if (value == '' || value == undefined) {
                            return value;
                        }
                        var myDate = new Date(value);
                        //获取当前年
                        var year = myDate.getFullYear();
                        //获取当前月
                        var month = myDate.getMonth() + 1;
                        month = month < 10 ? "0" + month : month;
                        //获取当前日
                        var date = myDate.getDate();
                        date = date < 10 ? "0" + date : date;
                        var h = myDate.getHours();       //获取当前小时数(0-23)
                        h = h < 10 ? "0" + h : h;
                        var m = myDate.getMinutes();     //获取当前分钟数(0-59)
                        m = m < 10 ? "0" + m : m;
                        var s = myDate.getSeconds();
                        s = s < 10 ? "0" + s : s;
                        var time = year + '-' + month + "-" + date;
                        return time;
                    }
                },
                {
                    title: '书架类名',
                    field: 'bookshelfClassname',
                },
                {
                    title: '所在楼层数',
                    field: 'bookshelfLayer',
                },
                {
                    title: '评论区状态',
                    field: 'ifOpenComment',
                    // formatter: function (value, row, index) {
                    //     var thisStr = '';
                    //     if (value == '0') {
                    //         thisStr = '关闭';
                    //     } else if (value == '1') {
                    //         thisStr = '打开';
                    //     }
                    //     return thisStr;
                    // }
                }
            ]
        }
    )
    ;
</script>
